package cn.bgs.controller;

import cn.bgs.DealershipManagement.pojo.VehicleArea;
import cn.bgs.service.Cwlservice;
import cn.bgs.utils.R;
import cn.bgs.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/car")
public class CwlContorller {

    @Autowired
    Cwlservice cwlservice;

    @RequestMapping("/selectAllinfo")
    public R selectAllinfo(@RequestBody AreaVo areaVo) {
        System.out.println("----:" + areaVo);
        return cwlservice.selectAllinfo(areaVo);
    }

    //    修改区域信息
    @PostMapping("/updateInfo")
    public R updateInfo(@RequestBody VehicleArea vehicleArea) {
        if (cwlservice.updateInfo(vehicleArea)) {
            return R.ok();
        }
        return R.error();
    }

    //    添加区域信息
    @PostMapping("/addInfo")
    public R addInfo(@RequestBody VehicleArea vehicleArea) {
        boolean a = cwlservice.addInfo(vehicleArea);
        return R.ok().data("data", a);
    }

    //    删除区域信息
    @GetMapping("delteInfo")
    public R delteInfo(Integer vehicleAreaId) {
        return cwlservice.delteInfo(vehicleAreaId);
    }

    //    查询小区信息
    @GetMapping("/info")
    public R info(CommunityVo communityVo) {
        return cwlservice.info(communityVo);
    }

    //     查询月卡信息
    @RequestMapping("selectPInfo")
    public R selectcarInfo(@RequestBody MonthVo monthVo) {
        return cwlservice.selectcarInfo(monthVo);
    }

    @PostMapping("/updateYKinfo")
    public R updateYKinfo(@RequestBody MonthVo monthVo) {
        System.out.println("----:" + monthVo);
        if (cwlservice.updateYKinfo(monthVo)) {
            return R.ok();
        }
        return R.error();
    }

    //  添加月卡信息
    @PostMapping("/addYkInfo")
    public R addYkInfo(@RequestBody MonthVo monthVo) {
        boolean a = cwlservice.addYkInfo(monthVo);
        return R.ok().data("data", a);
    }

    //      删除月卡信息
    @GetMapping("/delYkInfo")
    public R delYkInfo(Integer vehicleMonthcarId) {
        return cwlservice.delYkInfo(vehicleMonthcarId);
    }

    @RequestMapping("/selectnumInfo")
    public R selectnumInfo(@RequestBody CwnumVo cwnumVo) {
        System.out.println(cwnumVo);
        return cwlservice.selectnumInfo(cwnumVo);
    }

    //    查询所有用户
    @GetMapping("/selectAllUser")
    public R selectAllUser(UserVo userVo) {
        return cwlservice.selectAllUser(userVo);
    }

    //    添加车位信息
    @PostMapping("/insertCWinfo")
    public R insertCWinfo(@RequestBody CwnumVo cwnumVo) {
        boolean a = cwlservice.insertCWinfo(cwnumVo);
        return R.ok().data("data", a);
    }

    //    删除车位信息
    @GetMapping("delCWInfo")
    public R delCWInfo(Integer vehicleNumberId) {
        return cwlservice.delCWInfo(vehicleNumberId);
    }

    //    修改车位信息
    @PostMapping("/updateCwInfo")
    public R updateCwInfo(@RequestBody CwnumVo cwnumVo) {
        if (cwlservice.updateCwInfo(cwnumVo)) {
            return R.ok();
        }
        return R.error();
    }

    @GetMapping("CWinfo")
    public R CWinfo(CwnumVo cwnumVo) {
        return cwlservice.CWinfo(cwnumVo);
    }

    @RequestMapping("getCarinfo")
    public R getCarinfo(CarInfoVo carInfoVo) {
        return cwlservice.getCarinfo(carInfoVo);
    }

    @GetMapping("getAllFk")
    public R getAllFk(VisitorsRecordVo visitorsRecordVo) {
        return cwlservice.getAllFk(visitorsRecordVo);
    }

    @GetMapping("selectAllCar")
    public R selectAllCar(CarInfoVo carInfoVo) {
        return cwlservice.selectAllCar(carInfoVo);
    }

    @PostMapping("updateInfoC")
    public R updateInfoC(@RequestBody CwnumVo cwnumVo) {
        if (cwlservice.updateInfoC(cwnumVo)) {
            return R.ok();
        }
        return R.error();
    }
}